<?php
/* @var $this InventarioController */
/* @var $model Inventario */



Yii::import('zii.widgets.grid.CGridColumn');
 
class Total extends CGridColumn {
 
     private $_total = 0;

    public function renderDataCellContent($row, $data) { // $row number is ignored

    	if($data->IMPUESTO==1)
    		$this->_total += $data->PRECIOV+($data->PRECIOV*0.13);
    	else
    		$this->_total+= $data->PRECIOV;
 
        echo $this->_total;
        $this->_total =0;
    }
}


$this->breadcrumbs=array(
	'Inventario'=>array('index'),
	'Administrar',
);

$this->menu=array(
	array('label'=>'Listar Inventario', 'url'=>array('index')),
	array('label'=>'Crear Producto (Inventario)', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#inventario-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
$model= new Inventario;
?>
 

<h1>Administrador de Inventarios</h1>


<?php echo CHtml::link('Busqueda Avanzada','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'inventario-grid',
	'dataProvider'=>$model->existencias(),
	'filter'=>$model,
	'columns'=>array(
		'IDINVENTARIO',
		'DESCRIPCION',
		'CANTIDAD',
		'PRECIOV',
		array(
            'header' => 'Costo',
            'class'  => 'Total',
		),
		array(
			'class'=>'CButtonColumn',
		),
	),
)); ?>
